package cn.com.dcsgo.controller;

import cn.com.dcsgo.result.Result;
import cn.com.dcsgo.security.AuthContextHolder;
import cn.com.dcsgo.service.SkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * SkuController
 *
 * @author Dcsgo
 * @since 2025/5/7 上午8:38
 */
@Api(tags = "商品")
@RestController
@RequestMapping("weixin/home/item")
@RequiredArgsConstructor
public class SkuController {
    private final SkuService skuService;

    @GetMapping("{skuId}")
    @ApiOperation("通过skuId获取商品详细信息")
    public Result<Map<String, Object>> getSkuInfo(@PathVariable Long skuId) {
        Long userId = AuthContextHolder.getUserId();
        return Result.ok(skuService.getSkuInfo(skuId, userId));
    }
}
